package GBP;

/**
 * GraphNode.java
 * Created: 2005-12-22 10:30
**/

/**
 * This class defines the node of the graphs
 * for the Graph-Bipartitioning-Problem.
 *
 * @author T.S.Yo
**/

public class GraphNode {
	private int id;                  // Node ID
	private double[] position;       // Geometrical position of this node
	private int [] neighbors;        // Neighbors of this node
	
//---------------------------------------------------------------------
// Constructor    
	/** Full-parameter constructor **/
	public GraphNode( int id, double[] pos, int [] neib ) {
		this.id         = id;
		this.position   = pos;
		this.neighbors = neib;
	}

	/** Constructor without position (for G-graph) **/
	public GraphNode( int id, int [] neib ) {
		this.id        = id;
		this.neighbors = neib;
	}
	
//---------------------------------------------------------------------
// Methods to access private members    
	//returns the id
	public int getId() {
		return id;
	}
	
	//returns the ids of the neighbours
	public int [] getNeighbors() {
		return neighbors;
	}
	
	//returns the number of neighbours
	public int getNumNeighbors() {
		return neighbors.length;
	}
	
	//returns the position
	public double [] getPosition() {
		return position;
	}
//---------------------------------------------------------------------
// Overriding toString() to show the GraphNode
	public String toString() {
		String result = "    Node "+ id +"    neighbours: ";
		if( neighbors.length == 0 )
			result += "-";
		else {
			result += neighbors[ 0 ];
			for( int i = 1; i < neighbors.length; i++ )
				result += ", "+ neighbors[ i ];
		}		
		return result;
	}	
}
